#ifndef COMMOM_HPP
#define COMMOM_HPP
#include <iostream>
#include <string>
#include <cerrno>
#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#define mode 0666
#define Path "./pipe"

using namespace std;

class Pipe
{
public:
    Pipe(const string &path=Path)
    :_path(path)
    {
        umask(0);
        int n=mkfifo(_path.c_str(),mode);
        if(n==0)
        {
            cout<<"mkfifo succuss"<<endl;
        }
        else
        {
            cerr<<"mkfifo failed error:"<<errno<<",errorstring"<<strerror(errno)<<endl;
        }
    }

    ~Pipe()
    {
        int n=unlink(_path.c_str());
        if(n==0)
        {
            cout<<"remove pipe succuss,pipe path:"<<_path<<endl;
        }
        else
        {
            cerr<<"remove pipe error errno code:"<<errno<<"strerror:"<<strerror(errno)<<endl;
        }
    }
private:
    string _path;
};














#endif